Public Class ConnectLog
    Private mlID As Long
    Private mlDatabaseID As Long
    Private mlSessionID As Long
    Private msCreateDate As String = Now
    Private msLastDetectDate As String = Now

    Private mlConnect_SPID As Long
    Private msConnect_Status As String
    Private msConnect_HostName As String
    Private mlConnect_BlockID As Long
    Private msConnect_Command As String
    Private msConnect_LoginName As String
    Private msConnect_DatabaseName As String
    Private mbConnect_Current As Boolean
    Private mbConnect_IsHostProcess As Boolean

    Protected mbObjectExists As Boolean = False

    Public Sub New()

    End Sub

    Public Sub New(ByVal lID As Long)
        mlID = lID
        mbObjectExists = True
    End Sub

#Region "Properties"
    Public Property ID() As Long
        Get
            Return mlID
        End Get
        Set(ByVal value As Long)
            mlID = value
        End Set
    End Property

    Public Property DatabaseID() As Long
        Get
            Return mlDatabaseID
        End Get
        Set(ByVal value As Long)
            mlDatabaseID = value
        End Set
    End Property

    Public Property SessionID() As Long
        Get
            Return mlSessionID
        End Get
        Set(ByVal value As Long)
            mlSessionID = value
        End Set
    End Property

    Public Property CreateDate() As String
        Get
            Return msCreateDate
        End Get
        Set(ByVal value As String)
            msCreateDate = value
        End Set
    End Property

    Public Property LastDetectDate() As String
        Get
            Return msLastDetectDate
        End Get
        Set(ByVal value As String)
            msLastDetectDate = value
        End Set
    End Property

    Public Property Connect_SPID() As Long
        Get
            Return mlConnect_SPID
        End Get
        Set(ByVal value As Long)
            mlConnect_SPID = value
        End Set
    End Property

    Public Property Connect_Status() As String
        Get
            Return msConnect_Status
        End Get
        Set(ByVal value As String)
            msConnect_Status = value
        End Set
    End Property

    Public Property Connect_HostName() As String
        Get
            Return msConnect_HostName
        End Get
        Set(ByVal value As String)
            msConnect_HostName = value
        End Set
    End Property

    Public Property Connect_BlockID() As Long
        Get
            Return mlConnect_BlockID
        End Get
        Set(ByVal value As Long)
            mlConnect_BlockID = value
        End Set
    End Property

    Public Property Connect_Command() As String
        Get
            Return msConnect_Command
        End Get
        Set(ByVal value As String)
            msConnect_Command = value
        End Set
    End Property

    Public Property Connect_LoginName() As String
        Get
            Return msConnect_LoginName
        End Get
        Set(ByVal value As String)
            msConnect_LoginName = value
        End Set
    End Property

    Public Property Connect_DatabaseName() As Long
        Get
            Return msConnect_DatabaseName
        End Get
        Set(ByVal value As Long)
            msConnect_DatabaseName = value
        End Set
    End Property

    Public Property Connect_Current() As Boolean
        Get
            Return mbConnect_Current
        End Get
        Set(ByVal value As Boolean)
            mbConnect_Current = value
        End Set
    End Property

    Public Property Connect_IsHostProcess() As Boolean
        Get
            Return mbConnect_IsHostProcess
        End Get
        Set(ByVal value As Boolean)
            mbConnect_IsHostProcess = value
        End Set
    End Property
#End Region

#Region "Data"
    Public Sub Load()
        Dim oObject As New DBConnectlog

        oObject.Load(Me)
    End Sub

    Public Sub Save()
        Dim iTry As Integer = 0

        Dim oObject As New DBConnectLog

        Do
            Try
                If mbObjectExists = True Then
                    oObject.Update(Me)
                Else
                    Dim oNextID As New DBNextIDValue("DBConnectLog")
                    Dim lNextID As Long = oNextID.NextValue

                    Me.ID = lNextID

                    Me.CreateDate = Now
                    oObject.Add(Me)
                End If

                Exit Do

            Catch oEX As SqlClient.SqlException
                If iTry > 3 Then
                    Throw oEX
                End If
            End Try

            iTry = iTry + 1
        Loop Until iTry > 3
    End Sub

    Public Sub Delete()
        Dim oObject As New DBConnectLog

        oObject.Delete(Me)
    End Sub
#End Region
End Class
